/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.future.projects.imobiliaria.controllers;


import com.future.projects.imobiliaria.forms.PasswordFormBean;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.validation.Valid;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.ldap.userdetails.InetOrgPerson;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;

/**
 *
 * @author dctp
 */
@Controller
@RequestMapping("/settings")
public class SettingsController {

   

    @RequestMapping({"/", "/index", ""})
    public String showIndex(Model model) {
        return "settings";
    }

    
    @RequestMapping("/edit_password")
    public String showEditPassword(Model model) {
        PasswordFormBean passwordForm = new PasswordFormBean();
        model.addAttribute(passwordForm);
        return "settings/form_password";
    }

    @RequestMapping("/save_password")
    public String savePassword(Model model, @Valid PasswordFormBean passwordForm, BindingResult bindingResult, WebRequest request) {

        if (bindingResult.hasErrors()) {
            return "settings/form_password";
        }

        

        return "settings";
    }
}
